//
//  FihgtCollectionView.m
//  Associated Press indiana
//
//  Created by MK-MAC-001 on 15/7/20.
//  Copyright (c) 2015年 客官大大. All rights reserved.
//

#import "FihgtCollectionView.h"
#import "AppDelegate.h"
#import "CollectionViewCell.h"
@implementation FihgtCollectionView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createMYview];
    }
    return self;
}
-(void)createMYview
{
    UICollectionViewFlowLayout *laout = [[UICollectionViewFlowLayout alloc] init];
    laout.itemSize = CGSizeMake(200, 200);
    laout.scrollDirection = UICollectionViewScrollDirectionVertical;
    laout.minimumInteritemSpacing = 0;
    laout.minimumLineSpacing = 0;
    self.collectionview = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height-64) collectionViewLayout:laout];
    _collectionview.delegate = self;
    _collectionview.dataSource = self;
    [_collectionview registerClass:[CollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
    _collectionview.backgroundColor = [UIColor whiteColor];
    _collectionview.pagingEnabled = YES;
    [self addSubview:_collectionview];
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 20;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    CollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];

    return cell;
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"%ld", indexPath.row);
}
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 3;
}

@end
